package com.controller;

import com.entity.Job;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/CheckJob")
public class CheckJob extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        int jobId = Integer.parseInt(req.getParameter("jobId"));
        System.out.println("jobId = " + jobId);
        String jobName = req.getParameter("jobName");
        String companyAddress = req.getParameter("companyAddress");
        String salary = req.getParameter("salary");
        String jobType = req.getParameter("jobType");
        String addTime = req.getParameter("addTime");

        Job job = new Job();
        job.setJobId(jobId);
        System.out.println("jobid = " + jobId);
        job.setJobName(jobName);
        job.setCompanyAddress(companyAddress);
        job.setSalary(salary);
        job.setJobType(jobType);
        job.setAddTime(addTime);
        HttpSession session = req.getSession();
        session.setAttribute("job", job);
//        req.getRequestDispatcher("${pageContext.request.contextPath}/jsp").forward(req,resp);
//        resp.sendRedirect("jsp/User/addResume.jsp");
        req.getRequestDispatcher("jsp/User/addResume.jsp").forward(req,resp);

    }
}
